<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <sx:head/>
    <title>My JSP 'showmessage.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	
	
	<script type="text/javascript" src="js/My97DatePicker/WdatePicker.js" ></script>  
	
	<link rel="stylesheet" type="text/css" href="css/showmess.css">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
	<script type="text/javascript">
		function showMessageContent(messageid){
		//显示详细消息内容
			window.showModalDialog("hzx/getmessage?type=show&m.messageid="+messageid,"",'dialogHeight:450px;dialogWidth:350px;dialogLeft:400px;dialogTop:200px;center:yes;middle:yes;help:no;resizable:no;location:no;status:no;scroll:no');
		}
		
		function showMessageTouser(messageid){
		//显示全部接收对象
			window.showModalDialog("hzx/getmessage?type=showtouser&m.messageid="+messageid,"",'dialogHeight:450px;dialogWidth:350px;dialogLeft:400px;dialogTop:200px;center:yes;middle:yes;help:no;resizable:no;location:no;status:no;scroll:no');
		}
	</script>
  </head>
  
  <body>
  	<p>>>当前位置：消息管理<p>
    <center>
    	<h3>消息管理</h3>
    	<hr/>
    	<form id="form1" action="hzx/searchbytime" method="post">
    	<div>
    	请输入填写信息的时间-----<img><br/>
    	开始时间：<input type="text" name="btime" id="beginTime" onclick="WdatePicker()"  />*--------
    	结束时间：<input type="text" name="etime" id="endTime" onclick="WdatePicker()"  />*
    	<input type="radio" name="search" id="day" value="day" />本日
    	<input type="radio" name="search" id="week" value="week" />本周
    	<input type="radio" name="search" id="month" value="month" />本月
    	<input type="submit" value="搜索"  />
    	
    	</div>
    	</form>
    	<div id="add">
    		<a href="hzx/messageactionone" id="aadd"><img src="<%=request.getContextPath() %>/img/write.gif" />添加新消息</a>
	    </div>
	    
 		<form id="form2" method="post">
 		<c:if test="${messagelist!=null}">
 		<div id="show">
 		<c:choose>
	    <c:when test="${!empty p.list}">
	    	<table>
	    		<tr>
	    			<th>消息标题</th>
	    			<th>消息类型</th>
	    			<th>消息内容</th>
	    			<th>创建者</th>
	    			<th>发送对象</th>
	    			<th>开始时间</th>
	    			<th>结束时间</th>
	    			<th>创建时间</th>
	    			<th>修改</th>
	    			<th>删除</th>
	    			<th>发布</th>
	    		</tr>
	    			
	    		<c:forEach items="${p.list}" var="m" varStatus="state">
	    			<tr>
	    				<td>${m.title}</td>
	    				<td>${m.messagetype.messagetypename}</td>
	    				<td>
	    					<c:choose>
	    						<c:when test="${fn:length(m.content)>6}">
	    							<a href="javascript:showMessageContent('${m.messageid}')">
	    								${fn:substring(m.content,0,6) }....
	    							</a>
	    						</c:when>
	    						<c:otherwise>${m.content}</c:otherwise>
	    					</c:choose>
	    				</td>
	    				<td>${m.userinfo.username}</td>
	    				<td>
					    <a href="javascript:showMessageTouser('${m.messageid}')">
					 	<c:forEach items="${countlist}" var="c" varStatus="cl">
					 	<c:if test="${state.count==cl.count}">
					 		<c:choose>
					    		<c:when test="${c==0}">所有人</c:when>
					    		<c:otherwise>
					    			<c:forEach items="${messagetouserList}" var="mtu">
					    				<c:if test="${m.messageid==mtu.message.messageid}">
						    				${mtu.userinfo.username}	
						    			</c:if>
					    			</c:forEach>
					    		</c:otherwise>
					    	</c:choose>
					    </c:if>
					 	</c:forEach>
					    </a>&nbsp;
	    				</td>
	    				<td>${m.begintime}</td>
	    				<td>${m.endtime}</td>
	    				<td>${m.recordtime}</td>
	    				<td>
	    				<input type="button" value="修改" onclick="javascript:document.getElementById('form2').action='hzx/getmessage?type=two&m.messageid=${m.messageid}';document.getElementById('form2').submit();"
	    					<c:if test="${m.ifpublish==1}">disabled="disabled"</c:if>
	    				>
	    				</td>
	    				<td><a href="javascript:document.getElementById('form2').action='hzx/messageactiondelete?type=delete&m.messageid=${m.messageid}';document.getElementById('form2').submit();" onclick="return confirm('确定删除吗？')">
	    					&nbsp;&nbsp;<img src="<%=request.getContextPath() %>/img/delete.gif">
	    					</a>
	    				</td>
	    				<td>
	    				
	    				<input type="button" value="发布" onclick="javascript:document.getElementById('form2').action='hzx/messageactionfabu?type=fabu&m.messageid=${m.messageid}';document.getElementById('form2').submit();"
	    					<c:if test="${m.ifpublish==1}">disabled="disabled"</c:if>
	    				>
	    				
	    				</td>
	    			</tr>
	    		</c:forEach>
	    	</table>
	    	<br/><br/>
	    	当前<s:property value="%{#session.p.currentPage}" />页&nbsp;&nbsp;&nbsp;&nbsp;
    		总共<s:property value="%{#session.p.totalPage}" />页&nbsp;&nbsp;&nbsp;&nbsp;
    		<s:a  href="hzx/haction?type=1&page=1">首页</s:a>&nbsp;&nbsp;&nbsp;&nbsp;
    		<s:a  href="hzx/haction?type=1&page=%{#session.p.currentPage-1}">上一页</s:a>&nbsp;&nbsp;&nbsp;
    		<s:a  href="hzx/haction?type=1&page=%{#session.p.currentPage+1}">下一页</s:a>&nbsp;&nbsp;&nbsp;
    		<s:a  href="hzx/haction?type=1&page=%{#session.p.totalPage}">末页</s:a>&nbsp;&nbsp;&nbsp;    
	 </c:when>
	 <c:otherwise>
	  <div id="nolist">没有查找到记录</div>
	 </c:otherwise>
	 </c:choose>
	 </div>	
	 </c:if>
	 </form>
    </center>
  </body>
</html>
